Hello,
I would like to use the split command with the character "}" as a delimiter inside a forvalues loop, but Stata interprets the character "}" as the closing curly bracket of the loop.
Here is the code I would like to run
forvalues yr=1980/2020 {
I have tried inserting a backslash before the "{" in the split command. I did it like this
split var, p(`"\}],""') limit(1) notrim
I was hoping that Stata would interpret the backslash as an escape character to avoid the "}" be interpreted as a regular-loop operator. It did work. However, the split command now misinterprets the delimiter to be used. It uses the delimiter "\}]," including a backslash which does not exist in the string variable var.
Do you know any fix for that?
Thank you so much for your help,
O.
I would like to use the split command with the character "}" as a delimiter inside a forvalues loop, but Stata interprets the character "}" as the closing curly bracket of the loop.
Here is the code I would like to run
forvalues yr=1980/2020 {
}
import delimited using "rawfile_`yr'.txt", delimiters("\t") clear stripquotes(no)
split var, p(`"}],""') limit(1) notrim
keep var1
rename var1 symbol
save symbol_`yr', replace
I have tried inserting a backslash before the "{" in the split command. I did it like this
split var, p(`"\}],""') limit(1) notrim
I was hoping that Stata would interpret the backslash as an escape character to avoid the "}" be interpreted as a regular-loop operator. It did work. However, the split command now misinterprets the delimiter to be used. It uses the delimiter "\}]," including a backslash which does not exist in the string variable var.
Do you know any fix for that?
Thank you so much for your help,
O.
Comment